/*
* Sun Public License Notice
*
* The contents of this file are subject to the Sun Public License
* Version 1.0 (the "License"). You may not use this file except in
* compliance with the License. A copy of the License is available at
* http://www.sun.com/
*
* The Original Code is Forte for Java, Community Edition. The Initial
* Developer of the Original Code is Sun Microsystems, Inc. Portions
* Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
*/
package org.netbeans.modules.antlr.editor.g;
import java.io.InputStream;
import java.io.Reader;
import java.io.IOException;
import java.util.Hashtable;
import antlr.CharScanner;
import antlr.InputBuffer;
import antlr.ByteBuffer;
import antlr.CharBuffer;
import antlr.Token;
import antlr.CommonToken;
import antlr.ScannerException;
import antlr.TokenStream;
import antlr.ANTLRHashString;
import antlr.LexerSharedInputState;
import antlr.collections.impl.BitSet;
public class ANTLRLexer extends antlr.CharScanner implements ANTLRTokenTypes, TokenStream
{
/**Convert 'c' to an integer char value. */
public static int escapeCharValue(String cs) {
//System.out.println("escapeCharValue("+cs+")");
if ( cs.charAt(1)!='\\' ) return 0;
switch ( cs.charAt(2) ) {
case 'b' : return '\b';
case 'r' : return '\r';
case 't' : return '\t';
case 'n' : return '\n';
case 'f' : return '\f';
case '"' : return '\"';
case '\'' :return '\'';
case '\\' :return '\\';
case 'u' :
// Unicode char
if (cs.length() != 8) {
return 0;
}
else {
return
Character.digit(cs.charAt(3), 16) * 16 * 16 * 16 +
Character.digit(cs.charAt(4), 16) * 16 * 16 +
Character.digit(cs.charAt(5), 16) * 16 +
Character.digit(cs.charAt(6), 16);
}
case '0' :
case '1' :
case '2' :
case '3' :
if ( cs.length()>5 && Character.isDigit(cs.charAt(4)) ) {
return (cs.charAt(2)-'0')*8*8 + (cs.charAt(3)-'0')*8 + (cs.charAt(4)-'0');
}
if ( cs.length()>4 && Character.isDigit(cs.charAt(3)) ) {
return (cs.charAt(2)-'0')*8 + (cs.charAt(3)-'0');
}
return cs.charAt(2)-'0';
case '4' :
case '5' :
case '6' :
case '7' :
if ( cs.length()>4 && Character.isDigit(cs.charAt(3)) ) {
return (cs.charAt(2)-'0')*8 + (cs.charAt(3)-'0');
}
return cs.charAt(2)-'0';
default :
return 0;
}
}
public static int tokenTypeForCharLiteral(String lit) {
if ( lit.length()>3 ) { // does char contain escape?
return escapeCharValue(lit);
}
else {
return lit.charAt(1);
}
}
public ANTLRLexer(InputStream in) {
this(new ByteBuffer(in));
}
public ANTLRLexer(Reader in) {
this(new CharBuffer(in));
}
public ANTLRLexer(InputBuffer ib) {
this(new LexerSharedInputState(ib));
}
public ANTLRLexer(LexerSharedInputState state) {
super(state);
literals = new Hashtable();
literals.put(new ANTLRHashString("options", this), new Integer(6));
literals.put(new ANTLRHashString("tokens", this), new Integer(5));
literals.put(new ANTLRHashString("TextColor", this), new Integer(4));
caseSensitiveLiterals = true;
setCaseSensitive(true);
}
public Token nextToken() throws IOException {
Token _rettoken=null;
tryAgain:
for (;;) {
Token _token = null;
int _ttype = Token.INVALID_TYPE;
resetText();
try { // for error handling
switch ( LA(1)) {
case '\t': case '\n': case '\r': case ' ':
{
mWS(true);
_rettoken=_returnToken;
break;
}
case '/':
{
mCOMMENT(true);
_rettoken=_returnToken;
break;
}
case ',':
{
mCOMMA(true);
_rettoken=_returnToken;
break;
}
case '?':
{
mQUESTION(true);
_rettoken=_returnToken;
break;
}
case '#':
{
mTREE_BEGIN(true);
_rettoken=_returnToken;
break;
}
case '(':
{
mLPAREN(true);
_rettoken=_returnToken;
break;
}
case ')':
{
mRPAREN(true);
_rettoken=_returnToken;
break;
}
case ':':
{
mCOLON(true);
_rettoken=_returnToken;
break;
}
case '*':
{
mSTAR(true);
_rettoken=_returnToken;
break;
}
case '+':
{
mPLUS(true);
_rettoken=_returnToken;
break;
}
case ';':
{
mSEMI(true);
_rettoken=_returnToken;
break;
}
case '^':
{
mCARET(true);
_rettoken=_returnToken;
break;
}
case '!':
{
mBANG(true);
_rettoken=_returnToken;
break;
}
case '|':
{
mOR(true);
_rettoken=_returnToken;
break;
}
case '~':
{
mNOT_OP(true);
_rettoken=_returnToken;
break;
}
case '}':
{
mRCURLY(true);
_rettoken=_returnToken;
break;
}
case '\'':
{
mCHAR_LITERAL(true);
_rettoken=_returnToken;
break;
}
case '"':
{
mSTRING_LITERAL(true);
_rettoken=_returnToken;
break;
}
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
case '8': case '9':
{
mINT(true);
_rettoken=_returnToken;
break;
}
case '[':
{
mARG_ACTION(true);
_rettoken=_returnToken;
break;
}
case '{':
{
mACTION(true);
_rettoken=_returnToken;
break;
}
case 'A': case 'B': case 'C': case 'D':
case 'E': case 'F': case 'G': case 'H':
case 'I': case 'J': case 'K': case 'L':
case 'M': case 'N': case 'O': case 'P':
case 'Q': case 'R': case 'S': case 'T':
case 'U': case 'V': case 'W': case 'X':
case 'Y': case 'Z':
{
mTOKEN_REF(true);
_rettoken=_returnToken;
break;
}
case 'a': case 'b': case 'c': case 'd':
case 'e': case 'f': case 'g': case 'h':
case 'i': case 'j': case 'k': case 'l':
case 'm': case 'n': case 'o': case 'p':
case 'q': case 'r': case 's': case 't':
case 'u': case 'v': case 'w': case 'x':
case 'y': case 'z':
{
mRULE_REF(true);
_rettoken=_returnToken;
break;
}
default:
if ((LA(1)=='=') && (LA(2)=='>')) {
mIMPLIES(true);
_rettoken=_returnToken;
}
else if ((LA(1)=='.') && (LA(2)=='.')) {
mRANGE(true);
_rettoken=_returnToken;
}
else if ((LA(1)=='=')) {
mASSIGN(true);
_rettoken=_returnToken;
}
else if ((LA(1)=='.')) {
mWILDCARD(true);
_rettoken=_returnToken;
}
else {
if (LA(1)==EOF_CHAR) {_returnToken = makeToken(Token.EOF_TYPE);}
else {throw new ScannerException("no viable alt for char: "+(char)LA(1),getLine());}
}
}
if ( _returnToken==null ) continue tryAgain; // found SKIP token
_ttype = _returnToken.getType();
_returnToken.setType(_ttype);
return _returnToken;
}
catch (ScannerException e) {
reportError(e);
consume();
}
}
}
public final void mWS(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = WS;
int _saveIndex;
{
switch ( LA(1)) {
case ' ':
{
match(' ');
break;
}
case '\t':
{
match('\t');
break;
}
case '\n':
{
match('\n');
if ( inputState.guessing==0 ) {
newline();
}
break;
}
default:
if ((LA(1)=='\r') && (LA(2)=='\n')) {
match('\r');
match('\n');
if ( inputState.guessing==0 ) {
newline();
}
}
else if ((LA(1)=='\r')) {
match('\r');
if ( inputState.guessing==0 ) {
newline();
}
}
else {
throw new ScannerException("no viable alt for char: "+(char)LA(1),getLine());
}
}
}
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mCOMMENT(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = COMMENT;
int _saveIndex;
Token t=null;
{
if ((LA(1)=='/') && (LA(2)=='/')) {
mSL_COMMENT(false);
}
else if ((LA(1)=='/') && (LA(2)=='*')) {
mML_COMMENT(true);
t=_returnToken;
if ( inputState.guessing==0 ) {
_ttype = t.getType();
}
}
else {
throw new ScannerException("no viable alt for char: "+(char)LA(1),getLine());
}
}
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
protected final void mSL_COMMENT(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = SL_COMMENT;
int _saveIndex;
match("//");
{
_loop813:
do {
if ((_tokenSet_0.member(LA(1)))) {
{
match(_tokenSet_0);
}
}
else {
break _loop813;
}
} while (true);
}
{
switch ( LA(1)) {
case '\n':
{
match('\n');
break;
}
case '\r':
{
match('\r');
{
if ((LA(1)=='\n')) {
match('\n');
}
else {
}
}
break;
}
default:
{
throw new ScannerException("no viable alt for char: "+(char)LA(1),getLine());
}
}
}
if ( inputState.guessing==0 ) {
newline();
}
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
protected final void mML_COMMENT(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = ML_COMMENT;
int _saveIndex;
match("/*");
{
if (((LA(1)=='*') && ((LA(2) >= '\3' && LA(2) <= '~')))&&( LA(2)!='/' )) {
match('*');
if ( inputState.guessing==0 ) {
_ttype = DOC_COMMENT;
}
}
else if (((LA(1) >= '\3' && LA(1) <= '~')) && ((LA(2) >= '\3' && LA(2) <= '~'))) {
}
else {
throw new ScannerException("no viable alt for char: "+(char)LA(1),getLine());
}
}
{
_loop820:
do {
switch ( LA(1)) {
case '\n':
{
match('\n');
if ( inputState.guessing==0 ) {
newline();
}
break;
}
case '\3': case '\4': case '\5': case '\6':
case '\7': case '\10': case '\t': case '\13':
case '\14': case '\16': case '\17': case '\20':
case '\21': case '\22': case '\23': case '\24':
case '\25': case '\26': case '\27': case '\30':
case '\31': case '\32': case '\33': case '\34':
case '\35': case '\36': case '\37': case ' ':
case '!': case '"': case '#': case '$':
case '%': case '&': case '\'': case '(':
case ')': case '+': case ',': case '-':
case '.': case '/': case '0': case '1':
case '2': case '3': case '4': case '5':
case '6': case '7': case '8': case '9':
case ':': case ';': case '<': case '=':
case '>': case '?': case '@': case 'A':
case 'B': case 'C': case 'D': case 'E':
case 'F': case 'G': case 'H': case 'I':
case 'J': case 'K': case 'L': case 'M':
case 'N': case 'O': case 'P': case 'Q':
case 'R': case 'S': case 'T': case 'U':
case 'V': case 'W': case 'X': case 'Y':
case 'Z': case '[': case '\\': case ']':
case '^': case '_': case '`': case 'a':
case 'b': case 'c': case 'd': case 'e':
case 'f': case 'g': case 'h': case 'i':
case 'j': case 'k': case 'l': case 'm':
case 'n': case 'o': case 'p': case 'q':
case 'r': case 's': case 't': case 'u':
case 'v': case 'w': case 'x': case 'y':
case 'z': case '{': case '|': case '}':
case '~':
{
{
match(_tokenSet_1);
}
break;
}
default:
if (((LA(1)=='*') && ((LA(2) >= '\3' && LA(2) <= '~')))&&( LA(2)!='/' )) {
match('*');
}
else if ((LA(1)=='\r') && (LA(2)=='\n')) {
match('\r');
match('\n');
if ( inputState.guessing==0 ) {
newline();
}
}
else if ((LA(1)=='\r') && ((LA(2) >= '\3' && LA(2) <= '~'))) {
match('\r');
if ( inputState.guessing==0 ) {
newline();
}
}
else {
break _loop820;
}
}
} while (true);
}
match("*/");
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mCOMMA(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = COMMA;
int _saveIndex;
match(',');
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mQUESTION(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = QUESTION;
int _saveIndex;
match('?');
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mTREE_BEGIN(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = TREE_BEGIN;
int _saveIndex;
match("#(");
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mLPAREN(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = LPAREN;
int _saveIndex;
match('(');
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mRPAREN(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = RPAREN;
int _saveIndex;
match(')');
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mCOLON(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = COLON;
int _saveIndex;
match(':');
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mSTAR(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = STAR;
int _saveIndex;
match('*');
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mPLUS(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = PLUS;
int _saveIndex;
match('+');
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mASSIGN(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = ASSIGN;
int _saveIndex;
match('=');
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mIMPLIES(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = IMPLIES;
int _saveIndex;
match("=>");
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mSEMI(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = SEMI;
int _saveIndex;
match(';');
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mCARET(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = CARET;
int _saveIndex;
match('^');
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mBANG(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = BANG;
int _saveIndex;
match('!');
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mOR(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = OR;
int _saveIndex;
match('|');
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mWILDCARD(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = WILDCARD;
int _saveIndex;
match('.');
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mRANGE(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = RANGE;
int _saveIndex;
match("..");
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mNOT_OP(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = NOT_OP;
int _saveIndex;
match('~');
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mRCURLY(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = RCURLY;
int _saveIndex;
match('}');
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mCHAR_LITERAL(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = CHAR_LITERAL;
int _saveIndex;
match('\'');
{
switch ( LA(1)) {
case '\\':
{
mESC(false);
break;
}
case '\3': case '\4': case '\5': case '\6':
case '\7': case '\10': case '\t': case '\n':
case '\13': case '\14': case '\r': case '\16':
case '\17': case '\20': case '\21': case '\22':
case '\23': case '\24': case '\25': case '\26':
case '\27': case '\30': case '\31': case '\32':
case '\33': case '\34': case '\35': case '\36':
case '\37': case ' ': case '!': case '"':
case '#': case '$': case '%': case '&':
case '(': case ')': case '*': case '+':
case ',': case '-': case '.': case '/':
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
case '8': case '9': case ':': case ';':
case '<': case '=': case '>': case '?':
case '@': case 'A': case 'B': case 'C':
case 'D': case 'E': case 'F': case 'G':
case 'H': case 'I': case 'J': case 'K':
case 'L': case 'M': case 'N': case 'O':
case 'P': case 'Q': case 'R': case 'S':
case 'T': case 'U': case 'V': case 'W':
case 'X': case 'Y': case 'Z': case '[':
case ']': case '^': case '_': case '`':
case 'a': case 'b': case 'c': case 'd':
case 'e': case 'f': case 'g': case 'h':
case 'i': case 'j': case 'k': case 'l':
case 'm': case 'n': case 'o': case 'p':
case 'q': case 'r': case 's': case 't':
case 'u': case 'v': case 'w': case 'x':
case 'y': case 'z': case '{': case '|':
case '}': case '~':
{
matchNot('\'');
break;
}
default:
{
throw new ScannerException("no viable alt for char: "+(char)LA(1),getLine());
}
}
}
match('\'');
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
protected final void mESC(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = ESC;
int _saveIndex;
match('\\');
{
switch ( LA(1)) {
case 'n':
{
match('n');
break;
}
case 'r':
{
match('r');
break;
}
case 't':
{
match('t');
break;
}
case 'b':
{
match('b');
break;
}
case 'f':
{
match('f');
break;
}
case '"':
{
match('"');
break;
}
case '\'':
{
match('\'');
break;
}
case '\\':
{
match('\\');
break;
}
case '0': case '1': case '2': case '3':
{
{
matchRange('0','3');
}
{
if (((LA(1) >= '0' && LA(1) <= '9')) && ((LA(2) >= '\3' && LA(2) <= '~'))) {
{
matchRange('0','9');
}
{
if (((LA(1) >= '0' && LA(1) <= '9')) && ((LA(2) >= '\3' && LA(2) <= '~'))) {
matchRange('0','9');
}
else if (((LA(1) >= '\3' && LA(1) <= '~'))) {
}
else {
throw new ScannerException("no viable alt for char: "+(char)LA(1),getLine());
}
}
}
else if (((LA(1) >= '\3' && LA(1) <= '~'))) {
}
else {
throw new ScannerException("no viable alt for char: "+(char)LA(1),getLine());
}
}
break;
}
case '4': case '5': case '6': case '7':
{
{
matchRange('4','7');
}
{
if (((LA(1) >= '0' && LA(1) <= '9')) && ((LA(2) >= '\3' && LA(2) <= '~'))) {
{
matchRange('0','9');
}
}
else if (((LA(1) >= '\3' && LA(1) <= '~'))) {
}
else {
throw new ScannerException("no viable alt for char: "+(char)LA(1),getLine());
}
}
break;
}
case 'u':
{
match('u');
mXDIGIT(false);
mXDIGIT(false);
mXDIGIT(false);
mXDIGIT(false);
break;
}
default:
{
throw new ScannerException("no viable alt for char: "+(char)LA(1),getLine());
}
}
}
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mSTRING_LITERAL(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = STRING_LITERAL;
int _saveIndex;
match('"');
{
_loop843:
do {
switch ( LA(1)) {
case '\\':
{
mESC(false);
break;
}
case '\3': case '\4': case '\5': case '\6':
case '\7': case '\10': case '\t': case '\n':
case '\13': case '\14': case '\r': case '\16':
case '\17': case '\20': case '\21': case '\22':
case '\23': case '\24': case '\25': case '\26':
case '\27': case '\30': case '\31': case '\32':
case '\33': case '\34': case '\35': case '\36':
case '\37': case ' ': case '!': case '#':
case '$': case '%': case '&': case '\'':
case '(': case ')': case '*': case '+':
case ',': case '-': case '.': case '/':
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
case '8': case '9': case ':': case ';':
case '<': case '=': case '>': case '?':
case '@': case 'A': case 'B': case 'C':
case 'D': case 'E': case 'F': case 'G':
case 'H': case 'I': case 'J': case 'K':
case 'L': case 'M': case 'N': case 'O':
case 'P': case 'Q': case 'R': case 'S':
case 'T': case 'U': case 'V': case 'W':
case 'X': case 'Y': case 'Z': case '[':
case ']': case '^': case '_': case '`':
case 'a': case 'b': case 'c': case 'd':
case 'e': case 'f': case 'g': case 'h':
case 'i': case 'j': case 'k': case 'l':
case 'm': case 'n': case 'o': case 'p':
case 'q': case 'r': case 's': case 't':
case 'u': case 'v': case 'w': case 'x':
case 'y': case 'z': case '{': case '|':
case '}': case '~':
{
matchNot('"');
break;
}
default:
{
break _loop843;
}
}
} while (true);
}
match('"');
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
protected final void mXDIGIT(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = XDIGIT;
int _saveIndex;
switch ( LA(1)) {
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
case '8': case '9':
{
matchRange('0','9');
break;
}
case 'a': case 'b': case 'c': case 'd':
case 'e': case 'f':
{
matchRange('a','f');
break;
}
case 'A': case 'B': case 'C': case 'D':
case 'E': case 'F':
{
matchRange('A','F');
break;
}
default:
{
throw new ScannerException("no viable alt for char: "+(char)LA(1),getLine());
}
}
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
protected final void mDIGIT(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = DIGIT;
int _saveIndex;
matchRange('0','9');
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
protected final void mVOCAB(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = VOCAB;
int _saveIndex;
matchRange('\3','\176');
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mINT(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = INT;
int _saveIndex;
{
int _cnt858=0;
_loop858:
do {
if (((LA(1) >= '0' && LA(1) <= '9'))) {
matchRange('0','9');
}
else {
if ( _cnt858>=1 ) { break _loop858; } else {throw new ScannerException("no viable alt for char: "+(char)LA(1),getLine());}
}
_cnt858++;
} while (true);
}
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mARG_ACTION(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = ARG_ACTION;
int _saveIndex;
mNESTED_ARG_ACTION(false);
if ( inputState.guessing==0 ) {
///*setText(Tool.stripFrontBack(getText(), "[", "]"));*/
}
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
protected final void mNESTED_ARG_ACTION(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = NESTED_ARG_ACTION;
int _saveIndex;
match('[');
{
_loop862:
do {
switch ( LA(1)) {
case '[':
{
mNESTED_ARG_ACTION(false);
break;
}
case '\n':
{
match('\n');
if ( inputState.guessing==0 ) {
newline();
}
break;
}
case '\'':
{
mCHAR_LITERAL(false);
break;
}
case '"':
{
mSTRING_LITERAL(false);
break;
}
case '\3': case '\4': case '\5': case '\6':
case '\7': case '\10': case '\t': case '\13':
case '\14': case '\16': case '\17': case '\20':
case '\21': case '\22': case '\23': case '\24':
case '\25': case '\26': case '\27': case '\30':
case '\31': case '\32': case '\33': case '\34':
case '\35': case '\36': case '\37': case ' ':
case '!': case '#': case '$': case '%':
case '&': case '(': case ')': case '*':
case '+': case ',': case '-': case '.':
case '/': case '0': case '1': case '2':
case '3': case '4': case '5': case '6':
case '7': case '8': case '9': case ':':
case ';': case '<': case '=': case '>':
case '?': case '@': case 'A': case 'B':
case 'C': case 'D': case 'E': case 'F':
case 'G': case 'H': case 'I': case 'J':
case 'K': case 'L': case 'M': case 'N':
case 'O': case 'P': case 'Q': case 'R':
case 'S': case 'T': case 'U': case 'V':
case 'W': case 'X': case 'Y': case 'Z':
case '\\': case '^': case '_': case '`':
case 'a': case 'b': case 'c': case 'd':
case 'e': case 'f': case 'g': case 'h':
case 'i': case 'j': case 'k': case 'l':
case 'm': case 'n': case 'o': case 'p':
case 'q': case 'r': case 's': case 't':
case 'u': case 'v': case 'w': case 'x':
case 'y': case 'z': case '{': case '|':
case '}': case '~':
{
matchNot(']');
break;
}
default:
if ((LA(1)=='\r') && (LA(2)=='\n')) {
match('\r');
match('\n');
if ( inputState.guessing==0 ) {
newline();
}
}
else if ((LA(1)=='\r') && ((LA(2) >= '\3' && LA(2) <= '~'))) {
match('\r');
if ( inputState.guessing==0 ) {
newline();
}
}
else {
break _loop862;
}
}
} while (true);
}
match(']');
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mACTION(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = ACTION;
int _saveIndex;
int actionLine=getLine();
mNESTED_ACTION(false);
{
if ((LA(1)=='?')) {
match('?');
if ( inputState.guessing==0 ) {
_ttype = SEMPRED;
}
}
else {
}
}
if ( inputState.guessing==0 ) {
if ( _ttype==ACTION ) {
///*setText(Tool.stripFrontBack(getText(), "{", "}"));*/
}
else {
///*setText(Tool.stripFrontBack(getText(), "{", "}?"));*/
}
CommonToken t = new CommonToken(_ttype,new String(text.getBuffer(),_begin,text.length()-_begin));
t.setLine(actionLine); // set action line to start
_token = t;
}
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
/**
Note that the predicate "{true} was added before '~}'. The reason is that
ANTLR's code generation put "COMMENT" in the default case of a switch, but
the '~}' was in a case, so '~}' was always matched for '/'. Adding the
sempred caused '~}' to put put in the default case as well. Finally, the
extra '/' alternative had to be added, because '~}' does not match the '/'.
The '/' alt also has a sempred, to force it into the default case. Ack!
This seems too hard, but it works.
*/
protected final void mNESTED_ACTION(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = NESTED_ACTION;
int _saveIndex;
match('{');
{
_loop867:
do {
switch ( LA(1)) {
case '\n':
{
match('\n');
if ( inputState.guessing==0 ) {
newline();
}
break;
}
case '{':
{
mNESTED_ACTION(false);
break;
}
case '\'':
{
mCHAR_LITERAL(false);
break;
}
case '"':
{
mSTRING_LITERAL(false);
break;
}
default:
if ((LA(1)=='\r') && (LA(2)=='\n')) {
match('\r');
match('\n');
if ( inputState.guessing==0 ) {
newline();
}
}
else if ((LA(1)=='\r') && ((LA(2) >= '\3' && LA(2) <= '~'))) {
match('\r');
if ( inputState.guessing==0 ) {
newline();
}
}
else if (((LA(1)=='/') && (LA(2)=='*'||LA(2)=='/'))&&(LA(2)=='/'||LA(2)=='*')) {
mCOMMENT(false);
}
else if (((LA(1)=='/') && ((LA(2) >= '\3' && LA(2) <= '~')))&&(true)) {
match('/');
}
else if (((_tokenSet_2.member(LA(1))))&&(true)) {
matchNot('}');
}
else {
break _loop867;
}
}
} while (true);
}
match('}');
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mTOKEN_REF(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = TOKEN_REF;
int _saveIndex;
matchRange('A','Z');
{
_loop870:
do {
switch ( LA(1)) {
case 'a': case 'b': case 'c': case 'd':
case 'e': case 'f': case 'g': case 'h':
case 'i': case 'j': case 'k': case 'l':
case 'm': case 'n': case 'o': case 'p':
case 'q': case 'r': case 's': case 't':
case 'u': case 'v': case 'w': case 'x':
case 'y': case 'z':
{
matchRange('a','z');
break;
}
case 'A': case 'B': case 'C': case 'D':
case 'E': case 'F': case 'G': case 'H':
case 'I': case 'J': case 'K': case 'L':
case 'M': case 'N': case 'O': case 'P':
case 'Q': case 'R': case 'S': case 'T':
case 'U': case 'V': case 'W': case 'X':
case 'Y': case 'Z':
{
matchRange('A','Z');
break;
}
case '_':
{
match('_');
break;
}
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
case '8': case '9':
{
matchRange('0','9');
break;
}
default:
{
break _loop870;
}
}
} while (true);
}
_ttype = testLiteralsTable(_ttype);
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mRULE_REF(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = RULE_REF;
int _saveIndex;
int t=0;
t=mINTERNAL_RULE_REF(false);
if ( inputState.guessing==0 ) {
_ttype=t;
}
{
if (true&&(t==LITERAL_options)) {
mWS_LOOP(false);
{
if ((LA(1)=='{')) {
match('{');
if ( inputState.guessing==0 ) {
_ttype = OPTIONS;
}
}
else {
}
}
}
else if (true&&(t==LITERAL_tokens)) {
mWS_LOOP(false);
{
if ((LA(1)=='{')) {
match('{');
if ( inputState.guessing==0 ) {
_ttype = TOKENS;
}
}
else {
}
}
}
else {
}
}
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
protected final int mINTERNAL_RULE_REF(boolean _createToken) throws ScannerException, IOException {
int t;
int _ttype; Token _token=null; int _begin=text.length();
_ttype = INTERNAL_RULE_REF;
int _saveIndex;
t = RULE_REF;
matchRange('a','z');
{
_loop880:
do {
switch ( LA(1)) {
case 'a': case 'b': case 'c': case 'd':
case 'e': case 'f': case 'g': case 'h':
case 'i': case 'j': case 'k': case 'l':
case 'm': case 'n': case 'o': case 'p':
case 'q': case 'r': case 's': case 't':
case 'u': case 'v': case 'w': case 'x':
case 'y': case 'z':
{
matchRange('a','z');
break;
}
case 'A': case 'B': case 'C': case 'D':
case 'E': case 'F': case 'G': case 'H':
case 'I': case 'J': case 'K': case 'L':
case 'M': case 'N': case 'O': case 'P':
case 'Q': case 'R': case 'S': case 'T':
case 'U': case 'V': case 'W': case 'X':
case 'Y': case 'Z':
{
matchRange('A','Z');
break;
}
case '_':
{
match('_');
break;
}
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
case '8': case '9':
{
matchRange('0','9');
break;
}
default:
{
break _loop880;
}
}
} while (true);
}
if ( inputState.guessing==0 ) {
t = testLiteralsTable(t);
}
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
return t;
}
protected final void mWS_LOOP(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = WS_LOOP;
int _saveIndex;
{
_loop877:
do {
if ((_tokenSet_3.member(LA(1)))) {
mWS(false);
}
else {
break _loop877;
}
} while (true);
}
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
protected final void mWS_OPT(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = WS_OPT;
int _saveIndex;
{
if ((_tokenSet_3.member(LA(1)))) {
mWS(false);
}
else {
}
}
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
protected final void mNOT_USEFUL(boolean _createToken) throws ScannerException, IOException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = NOT_USEFUL;
int _saveIndex;
boolean synPredMatched885 = false;
if (((LA(1)=='a'))) {
int _m885 = mark();
synPredMatched885 = true;
inputState.guessing++;
try {
{
match('a');
}
}
catch (ScannerException pe) {
synPredMatched885 = false;
}
rewind(_m885);
inputState.guessing--;
}
if ( synPredMatched885 ) {
match('a');
}
else if ((LA(1)=='a')) {
match('a');
}
else {
throw new ScannerException("no viable alt for char: "+(char)LA(1),getLine());
}
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
private static final long _tokenSet_0_data_[] = { -9224L, 9223372036854775807L, 0L, 0L };
public static final BitSet _tokenSet_0 = new BitSet(_tokenSet_0_data_);
private static final long _tokenSet_1_data_[] = { -4398046520328L, 9223372036854775807L, 0L, 0L };
public static final BitSet _tokenSet_1 = new BitSet(_tokenSet_1_data_);
private static final long _tokenSet_2_data_[] = { -141304424047624L, 6341068275337658367L, 0L, 0L };
public static final BitSet _tokenSet_2 = new BitSet(_tokenSet_2_data_);
private static final long _tokenSet_3_data_[] = { 4294977024L, 0L, 0L };
public static final BitSet _tokenSet_3 = new BitSet(_tokenSet_3_data_);
}